<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/site.css" rel="stylesheet" type="text/css" />
    <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />  
<title>My-Memories</title>
</head>

<body>
<div class="banner">
<div style="width:75%; height:100%;">
	<marquee scrollamount="15" direction="up" behavior="alternate"><marquee scrollamount="15" direction="right" behavior="alternate"><img src="images/butterfly.gif" /></marquee></marquee>
</div>

</div>
<div class="sidebar">

<img src="images/latestPost.png" width="240" height="50" alt="Latest Posts" />
<table width="200" border="0" cellpadding="5px">
	<?php 
		include_once("config/util.php");
		validate();
		include_once("config/database.php");			
		$db = new database();
		$db->setQuery("SELECT * FROM `posts` GROUP BY id DESC LIMIT 0 , 10");
		if($db->numRecord()>0)
		{
			 $posts = $db->fetchAll();
			 while($p = mysql_fetch_array($posts))
			{
				echo "<tr>";
				echo '<td><img src="images/rose2.gif" width="39" height="41" /></td>';
				echo "<td><a href='index.php?q=posts&p=".$p["id"]."'>".$p["title"]."</a></td>";
				echo "</tr>";
			}
		}
		

	?>
</table>

</div>

<div class="content">
	<?php 
		if(isset($_REQUEST["q"]))
		{
			if(mysql_real_escape_string($_REQUEST["q"])=="posts")
			{
				include("posts.php");
			}
			else if(mysql_real_escape_string($_REQUEST["q"])=="logout")
			{
				setcookie ("username", "", time() - 3600);
				goToPage("login.php");
			}
		}		
		else
		{
			goToPage("index.php?q=posts&p=latest");
		}
	?>
</div>


<div id="login_panel">
	<span style="color:#009; font-weight:bolder">User:</span>
    <span style="color:#909; font-weight:bolder"> <?php echo $_COOKIE["username"] ;?> </span> &nbsp;(<a href="index.php?q=logout">Đăng xuất</a>)
    
</div>

</body>
</html>